#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
const int N = 2e5 + 10;
vector<int> adj[N];
vector<int> close;
int par[N];
bool ans[N];
bool check[N];
int find(int x) { return par[x] = x == par[x] ? x : find(par[x]); }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) par[i] = i;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    close.push_back(c);
  }
  // 倒序遍历close，逐个“打开”
  int cc = 0;  // Connected Composnets
  for (int i = n - 1; i >= 0; --i) {
    cc++;
    int u = close[i];
    check[u] = true;
    for (auto v : adj[u]) {
      if (check[v]) {
        int fu = find(u), fv = find(v);
        if (fu != fv) {
          cc--;
          par[fu] = fv;
        }
      }
    }
    if (cc == 1) ans[i] = true;
  }
  for (int i = 0; i < n; ++i) {
    cout << (ans[i] ? "YES\n" : "NO\n");
  }
  return 0;
}
